<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 7.3.0">

  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" integrity="sha256-wiz7ZSCn/btzhjKDQBms9Hx4sSeUYsDrTLg7roPstac=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.css" integrity="sha256-6cQIC71/iBIYXFK+0RHAvwmjwWzkWd+r7v/BX3/vZDc=" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"sumumm.github.io","root":"/","images":"/images","scheme":"Gemini","darkmode":false,"version":"8.19.2","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":{"enable":true,"style":"mac"},"fold":{"enable":true,"height":300},"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"stickytabs":false,"motion":{"enable":true,"async":true,"transition":{"menu_item":"fadeInDown","post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="本文主要是makefile——文件包含和嵌套执行相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:type" content="article">
<meta property="og:title" content="LV02-05-Makefile-06-文件包含和嵌套执行">
<meta property="og:url" content="https://sumumm.github.io/post/35083dd3.html">
<meta property="og:site_name" content="苏木">
<meta property="og:description" content="本文主要是makefile——文件包含和嵌套执行相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2022-03-23T05:57:15.000Z">
<meta property="article:modified_time" content="2025-06-13T16:25:56.990Z">
<meta property="article:author" content="苏木">
<meta property="article:tag" content="LV02-编译基础">
<meta property="article:tag" content="makefile">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="https://sumumm.github.io/post/35083dd3.html">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"https://sumumm.github.io/post/35083dd3.html","path":"post/35083dd3.html","title":"LV02-05-Makefile-06-文件包含和嵌套执行"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>LV02-05-Makefile-06-文件包含和嵌套执行 | 苏木</title>
  








    <script src="/js/browser_tools_disable.js"></script>

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<!-- hexo injector head_end start --><link rel="stylesheet" href="https://unpkg.com/hexo-next-tags-plus@latest/lib/tag_plus.css" media="defer" onload="this.media='all'"><!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <div class="column">
      <header class="header" itemscope itemtype="http://schema.org/WPHeader"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">苏木</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">我的学习之路</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger" aria-label="搜索" role="button">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu"><li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>苏木的家</a></li><li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类页<span class="badge">42</span></a></li><li class="menu-item menu-item-archives"><a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档页<span class="badge">673</span></a></li><li class="menu-item menu-item-flink"><a href="/flink/" rel="section"><i class="fa fa-link fa-fw"></i>友人帐</a></li><li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于我</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</header>
        
  
  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%B8%80%E3%80%81%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB"><span class="nav-text">一、文件包含</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F"><span class="nav-text">1.使用格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E6%90%9C%E7%B4%A2%E8%B7%AF%E5%BE%84"><span class="nav-text">2.搜索路径</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E5%BF%BD%E7%95%A5%E9%94%99%E8%AF%AF"><span class="nav-text">3.忽略错误</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#%E4%BA%8C%E3%80%81-Makefile-%E5%B5%8C%E5%A5%97%E6%89%A7%E8%A1%8C"><span class="nav-text">二、 Makefile 嵌套执行</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#1-%E4%BD%BF%E7%94%A8%E6%A0%BC%E5%BC%8F-1"><span class="nav-text">1.使用格式</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#2-%E5%8F%98%E9%87%8F%E4%BC%A0%E9%80%92"><span class="nav-text">2.变量传递</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#3-%E7%9B%B8%E5%85%B3-make-%E5%8F%82%E6%95%B0"><span class="nav-text">3.相关 make 参数</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#4-%E4%BD%BF%E7%94%A8%E5%AE%9E%E4%BE%8B"><span class="nav-text">4.使用实例</span></a></li></ol></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="苏木"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">苏木</p>
  <div class="site-description" itemprop="description">莫道桑榆晚，为霞尚满天</div>
</div>
<div class="site-state-wrap animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">673</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">42</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">43</span>
        <span class="site-state-item-name">标签</span>
      </div>
  </nav>
</div>
  <div class="links-of-author animated">
      <span class="links-of-author-item">
        <a href="https://github.com/sumumm" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;sumumm" rel="noopener me" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
  </div>

        </div>
      </div>
    </div>

    
  </aside>


    </div>

    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://sumumm.github.io/post/35083dd3.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="苏木">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="苏木">
      <meta itemprop="description" content="莫道桑榆晚，为霞尚满天">
    </span>

    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="LV02-05-Makefile-06-文件包含和嵌套执行 | 苏木">
      <meta itemprop="description" content="">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          LV02-05-Makefile-06-文件包含和嵌套执行
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2022-03-23 13:57:15" itemprop="dateCreated datePublished" datetime="2022-03-23T13:57:15+08:00">2022-03-23</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/" itemprop="url" rel="index"><span itemprop="name">嵌入式开发</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/" itemprop="url" rel="index"><span itemprop="name">01HQ课程体系</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV02-%E7%BC%96%E8%AF%91%E5%9F%BA%E7%A1%80/" itemprop="url" rel="index"><span itemprop="name">LV02-编译基础</span></a>
        </span>
    </span>

  
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>2.4k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>9 分钟</span>
    </span>
</div>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody"><p>本文主要是makefile——文件包含和嵌套执行相关笔记，若笔记中有错误或者不合适的地方，欢迎批评指正😃。</p>
<span id="more"></span>

<!-- Photo: https://fanhua-picture.oss-cn-hangzhou.aliyuncs.com/01%E5%B5%8C%E5%85%A5%E5%BC%8F%E5%BC%80%E5%8F%91/01HQ%E8%AF%BE%E7%A8%8B%E4%BD%93%E7%B3%BB/LV02-%E7%BC%96%E8%AF%91%E5%9F%BA%E7%A1%80/LV02-05-Makefile-06-%E6%96%87%E4%BB%B6%E5%8C%85%E5%90%AB%E5%92%8C%E5%B5%8C%E5%A5%97%E6%89%A7%E8%A1%8C/img/ -->

<details class="folding-tag" blue><summary> 点击查看使用工具及版本 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center" width=150px>Windows</td>        <td align="left">windows11</td>    </tr>    <tr>        <td align="center">Ubuntu</td>        <td align="left">Ubuntu16.04的64位版本</td>      </tr>    <tr>        <td align="center">VMware® Workstation 16 Pro</td>        <td align="left">16.2.3 build-19376536</td>      </tr>    <tr>        <td align="center">SecureCRT</td>        <td align="left">Version 8.7.2 (x64 build 2214)   -   正式版-2020年5月14日</td>      </tr>    <tr>        <td align="center">开发板</td>        <td align="left">正点原子 i.MX6ULL Linux阿尔法开发板</td>      </tr>    <tr>        <td align="center">uboot</td>        <td align="left">NXP官方提供的uboot，NXP提供的版本为uboot-imx-rel_imx_4.1.15_2.1.0_ga(使用的uboot版本为U-Boot 2016.03)</td>      </tr>    <tr>        <td align="center">linux内核</td>        <td align="left">linux-4.15(NXP官方提供)</td>      </tr>    <tr>        <td align="center">STM32开发板</td>        <td align="left">正点原子战舰V3(STM32F103ZET6)</td>      </tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看本文参考资料 </summary>
              <div class='content'>
              <table>    <tr><td align="center">参考方向  </td><td align="center">参考原文</td></tr>    <tr><td align="left"> Makefile </td><td align="left"><a href="" target="_blank"> 跟我一起写Makefile <i class="fa fa-external-link-alt"></i> </a></td></tr></table>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看相关文件下载 </summary>
              <div class='content'>
              <table>    <tr>        <td align="center">---</td>        <td align="left">--- <a href="" target="_blank">  <i class="fa fa-external-link-alt"></i></a></td>      </tr></table>
              </div>
            </details>



<details class="folding-tag" blue><summary> 点击查看文件搜索相关测试文件 </summary>
              <div class='content'>
              <p>各文件所在目录的结构如下：</p><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── main.c</span><br><span class="line">├── Makefile</span><br><span class="line">├── test1.c</span><br><span class="line">├── test1.h</span><br><span class="line">├── test2.c</span><br><span class="line">└── test2.h</span><br><span class="line"></span><br><span class="line"><span class="number">0</span> directories, <span class="number">6</span> files</span><br></pre></td></tr></table></figure><div class="tabs" id="tabname1"><ul class="nav-tabs"><li class="tab active"><a href="#tabname1-1">main.c</a></li><li class="tab"><a href="#tabname1-2">test1.c</a></li><li class="tab"><a href="#tabname1-3">test2.c</a></li><li class="tab"><a href="#tabname1-4">test1.h</a></li><li class="tab"><a href="#tabname1-5">test2.h</a></li></ul><div class="tab-content"><div class="tab-pane active" id="tabname1-1"><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;test1.h&quot;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&quot;test2.h&quot;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">int</span> <span class="title function_">main</span><span class="params">(<span class="type">int</span> argc, <span class="type">const</span> <span class="type">char</span> *argv[])</span></span><br><span class="line">&#123;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;This is main file!\n&quot;</span>);</span><br><span class="line">	test1Fun();</span><br><span class="line">	test2Fun();</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div><div class="tab-pane" id="tabname1-2"><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">test1Fun</span><span class="params">()</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;This is test1.c file\n&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div><div class="tab-pane" id="tabname1-3"><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;stdio.h&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">test2Fun</span><span class="params">()</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;This is test2.c file\n&quot;</span>);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></div><div class="tab-pane" id="tabname1-4"><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifndef</span> __TEST1_H__</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> __TEST1_H__</span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">test1Fun</span><span class="params">()</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure></div><div class="tab-pane" id="tabname1-5"><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">ifndef</span> __TEST2_H__</span></span><br><span class="line"><span class="meta">#<span class="keyword">define</span> __TEST2_H__</span></span><br><span class="line"></span><br><span class="line"><span class="type">void</span> <span class="title function_">test2Fun</span><span class="params">()</span>;</span><br><span class="line"></span><br><span class="line"><span class="meta">#<span class="keyword">endif</span></span></span><br></pre></td></tr></table></figure></div></div></div>
              </div>
            </details>

<h1 id="一、文件包含"><a href="#一、文件包含" class="headerlink" title="一、文件包含"></a><font size=3>一、文件包含</font></h1><p>像 C 语言一样，在  Makefile  中使用  include  关键字可以把别的  Makefile  包含进来，不过这个功能到目前为止我还没有使用过，就先记录在这里吧，后边遇到了再补充笔记。</p>
<h2 id="1-使用格式"><a href="#1-使用格式" class="headerlink" title="1.使用格式"></a><font size=3>1.使用格式</font></h2><p>使用格式如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">include &lt;filename&gt;</span><br></pre></td></tr></table></figure>

<p>【注意】</p>
<p>（1）在  include  前面可以有一些空字符，但是绝不能是 Tab 键开始。若要包含的多个文件，这些文件之间要使用空格分隔开。</p>
<p>（2）使用  include  包含进来的  Makefile  文件中，如果存在函数或者是变量的引用，它们会在包含的  Makefile  中展开。</p>
<p>（3）使用  include &lt;filenames&gt;  ， make  在处理程序的时候，文件列表中的任意一个文件不存在的时候或者是没有规则去创建这个文件的时候， make  程序将会提示错误并保存退出。</p>
<h2 id="2-搜索路径"><a href="#2-搜索路径" class="headerlink" title="2.搜索路径"></a><font size=3>2.搜索路径</font></h2><p>当  make  读取到  include  关键字的时候，会暂停读取当前的  Makefile ，而是去读  include  包含的文件，读取结束后再继读取当前的  Makefile  文件。如果文件都没有指定绝对路径或是相对路径的话， make  会在当前目录下首先寻找，如果当前目录下没有找到，那么， make  还会在下面的几个目录下找：</p>
<p>（1）如果  make  执行时，有 -I 或 –include-dir 参数，那么  make  就会在这个参数所指定 的目录下去寻找。</p>
<p>（2）如果目录 &#x2F;include （一般是： &#x2F;usr&#x2F;local&#x2F;bin  或 &#x2F;usr&#x2F;include ）存在的话， make  也会在这些文件夹下寻找文件。</p>
<p>如果有文件没有找到的话， make  会生成一条警告信息，但不会马上出现致命错误。它会继续载入其它的文件，一旦完成  Makefile  的读取， make  会再重试这些没有找到，或是不能读取的文件。如果还是不行， make  才会出现一条致命信息。</p>
<h2 id="3-忽略错误"><a href="#3-忽略错误" class="headerlink" title="3.忽略错误"></a><font size=3>3.忽略错误</font></h2><p>如果想让  make  不理那些无法读取的文件，而继续执行，我们可以在  include  前加一个减号 - 。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">-include &lt;filename&gt;</span><br></pre></td></tr></table></figure>

<p>这就表示，无论过程中出现什么错误，都不要报错继续执行。和其它版本  make  兼容 的相关命令是  sinclude ，其作用相同。</p>
<h1 id="二、-Makefile-嵌套执行"><a href="#二、-Makefile-嵌套执行" class="headerlink" title="二、 Makefile 嵌套执行"></a><font size=3>二、 Makefile 嵌套执行</font></h1><p>在一些大的工程中，我们会把我们不同模块或是不同功能的源文件放在不同的目录中，我们可以在每个目录中都书写一个该目录的  Makefile ，这有利于让我们的  Makefile  变得更加地简洁，而不至于把所有的东西全部写在一个  Makefile  中，这样不仅方便管理，而且可以迅速发现模块中的问题。</p>
<h2 id="1-使用格式-1"><a href="#1-使用格式-1" class="headerlink" title="1.使用格式"></a><font size=3>1.使用格式</font></h2><p>我们有一个子目录叫  subdir ，这个目录下有个  Makefile  文件，来指明了这个目录下文件的编译规则。这个时候，在总的 Makefile 中嵌套使用的语法格式如下：</p>
<figure class="highlight makefile"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 1.写法一</span></span><br><span class="line"><span class="section">subsystem:</span></span><br><span class="line">    cd subdir &amp;&amp; <span class="variable">$(MAKE)</span></span><br><span class="line">    </span><br><span class="line"><span class="comment"># 2.写法二</span></span><br><span class="line"><span class="comment"># CURDIR 此变量代表 make 的工作目录， -C 选项会使make命令进入指定目录下</span></span><br><span class="line">subsystem</span><br><span class="line">    <span class="variable">$(MAKE)</span> -C subdir</span><br></pre></td></tr></table></figure>

<p>当命令执行到上述的规则时，程序会进入到子目录中执行  make 。这就是嵌套执行  make ，我们把最外层的  Makefile  称为是总控  Makefile 。</p>
<h2 id="2-变量传递"><a href="#2-变量传递" class="headerlink" title="2.变量传递"></a><font size=3>2.变量传递</font></h2><p>总控  Makefile  的变量可以传递到下级的  Makefile  中，但是不会覆盖下层的  Makefile  中所定义的变量，除非指定了 -e 参数。如果需要传递变量到下级  Makefile  中，那么我们可以使用这样的声明方式来声明变量：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export &lt;variable ...&gt;</span><br></pre></td></tr></table></figure>

<p>如果这个变量不需要传递到下级，可以这样声明：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">unexport &lt;variable ...&gt;</span><br></pre></td></tr></table></figure>

<p>如果我们需要传递所有的变量到下一级，那么我们可以直接使用 export ：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export</span><br></pre></td></tr></table></figure>

<p><strong>【注意】</strong>有两个变量，一个是  SHELL ，一个是  MAKEFLAGS ，这两个变量不管是否  export ，其总是要传递到下层  Makefile  中，特别是  MAKEFILES  变量，其中包含了  make  的参数信息。但是  make  命令中的有几个参数并不往下传递，它们是 -C 、 -f 、 -h 、 -o 和 -W 。如果我们不想往下层传递参数，可以这样做：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">subsystem:</span><br><span class="line">	cd subdir &amp;&amp; $(MAKE) MAKEFLAGS=</span><br></pre></td></tr></table></figure>

<h2 id="3-相关-make-参数"><a href="#3-相关-make-参数" class="headerlink" title="3.相关 make 参数"></a><font size=3>3.相关 make 参数</font></h2><p> -w 或是 –print-directory 会在 make 的过程中输出一些信息，让我们看到目前的工作目录。比如，如果我们的下级  make  目录<br>是 &#x2F;home&#x2F;hk&#x2F;gnu&#x2F;make ，如果我们使用 make -w 来执行，那么当进入该目录时，我们会看到：  </p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make: Entering directory  /home/hk/gnu/make&#x27;.</span><br></pre></td></tr></table></figure>

<p>而在完成下层 make 后离开目录时，我们会看到：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">make: Leaving directory  /home/hk/gnu/make&#x27;.</span><br></pre></td></tr></table></figure>

<p>当我们使用 -C 参数来指定 make  下层  Makefile  时， -w 会被自动打开的。如果参数中有 -s （ –slient ） 或是 –no-print-directory ，那么， -w 总是失效的。  </p>
<h2 id="4-使用实例"><a href="#4-使用实例" class="headerlink" title="4.使用实例"></a><font size=3>4.使用实例</font></h2><p>首先来看一下文件结构如下：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">.</span><br><span class="line">├── fun1</span><br><span class="line">│   ├── fun1.c</span><br><span class="line">│   └── Makefile</span><br><span class="line">├── fun2</span><br><span class="line">│   ├── fun2.c</span><br><span class="line">│   └── Makefile</span><br><span class="line">├── include</span><br><span class="line">│   └── myinclude.h</span><br><span class="line">├── main</span><br><span class="line">│   ├── main.c</span><br><span class="line">│   └── Makefile</span><br><span class="line">├── Makefile</span><br><span class="line">└── obj</span><br><span class="line">    └── Makefile</span><br></pre></td></tr></table></figure>

<details class="folding-tag" blue><summary> 点击查看相关文件内容 </summary>
              <div class='content'>
              <p>以下均为 . 下目录。</p><div class="tabs" id="tabname2"><ul class="nav-tabs"><li class="tab active"><a href="#tabname2-1">main</a></li><li class="tab"><a href="#tabname2-2">fun1</a></li><li class="tab"><a href="#tabname2-3">fun2</a></li><li class="tab"><a href="#tabname2-4">fun2</a></li><li class="tab"><a href="#tabname2-5">obj</a></li></ul><div class="tab-content"><div class="tab-pane active" id="tabname2-1"><details class="folding-tag" blue><summary> 点击查看 ./main/main.c 文件内容 </summary>              <div class='content'>              <figure class="highlight shell"><figcaption><span>./main/main.c</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">include <span class="string">&quot;myinclude.h&quot;</span></span></span><br><span class="line">void printfun1();</span><br><span class="line">void printfun2();</span><br><span class="line"></span><br><span class="line">int main(int argc, const char *argv[])</span><br><span class="line">&#123;</span><br><span class="line">	printfun1();</span><br><span class="line">	printfun2();</span><br><span class="line">	</span><br><span class="line">	printf(&quot;end main\n&quot;);</span><br><span class="line">	return 0;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>              </div>            </details><details class="folding-tag" blue><summary> 点击查看 ./main/Makefile 文件内容 </summary>              <div class='content'>              <figure class="highlight makefile"><figcaption><span>./main/Makefile</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">../$(OBJS_DIR)/main.o:main.c</span></span><br><span class="line">	<span class="variable">$(CC)</span> -c <span class="variable">$^</span> -I ../<span class="variable">$(H_DIR)</span> -o <span class="variable">$@</span></span><br></pre></td></tr></table></figure>              </div>            </details></div><div class="tab-pane" id="tabname2-2"><details class="folding-tag" blue><summary> 点击查看 ./fun1/fun1.c 文件内容 </summary>              <div class='content'>              <figure class="highlight shell"><figcaption><span>./fun1/fun1.c</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">include &lt;stdio.h&gt;</span></span><br><span class="line"></span><br><span class="line">void printfun1()</span><br><span class="line">&#123;</span><br><span class="line">	printf(&quot;this is fun1!\n&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>              </div>            </details><details class="folding-tag" blue><summary> 点击查看 ./fun1/Makefile 文件内容 </summary>              <div class='content'>              <figure class="highlight makefile"><figcaption><span>./fun1/Makefile</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">../$(OBJS_DIR)/fun1.o:fun1.c</span></span><br><span class="line">	<span class="variable">$(CC)</span> -c <span class="variable">$^</span> -o <span class="variable">$@</span></span><br></pre></td></tr></table></figure>              </div>            </details></div><div class="tab-pane" id="tabname2-3"><details class="folding-tag" blue><summary> 点击查看 ./fun2/fun2.c 文件内容 </summary>              <div class='content'>              <figure class="highlight shell"><figcaption><span>./fun1/fun1.c</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">include &lt;stdio.h&gt;</span></span><br><span class="line"></span><br><span class="line">void printfun2()</span><br><span class="line">&#123;</span><br><span class="line">	printf(&quot;this is fun2!\n&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>              </div>            </details><details class="folding-tag" blue><summary> 点击查看 ./fun2/Makefile 文件内容 </summary>              <div class='content'>              <figure class="highlight makefile"><figcaption><span>./fun2/Makefile</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">../$(OBJS_DIR)/fun2.o:fun2.c</span></span><br><span class="line">	<span class="variable">$(CC)</span> -c <span class="variable">$^</span> -o <span class="variable">$@</span></span><br></pre></td></tr></table></figure>              </div>            </details></div><div class="tab-pane" id="tabname2-4"><figure class="highlight shell"><figcaption><span>./include/myinclude.h</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta prompt_">#</span><span class="language-bash">include &lt;stdio.h&gt;</span></span><br></pre></td></tr></table></figure></div><div class="tab-pane" id="tabname2-5"><figure class="highlight makefile"><figcaption><span>./obj/Makefile</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">../$(BIN_DIR)/$(BIN):<span class="variable">$(OBJS)</span></span></span><br><span class="line">	<span class="variable">$(CC)</span> -o <span class="variable">$@</span> <span class="variable">$^</span></span><br></pre></td></tr></table></figure></div></div></div>
              </div>
            </details>

<details class="folding-tag" blue><summary> 点击查看 总控 Makefile 文件内容 </summary>
              <div class='content'>
              <figure class="highlight makefile"><figcaption><span>./Makefile</span></figcaption><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br></pre></td><td class="code"><pre><span class="line">CC=gcc</span><br><span class="line">SUBDIRS=fun1 \</span><br><span class="line">		fun2 \</span><br><span class="line">		main \</span><br><span class="line">		obj</span><br><span class="line">OBJS=fun1.o fun2.o main.o</span><br><span class="line">BIN=myapp</span><br><span class="line">OBJS_DIR=obj</span><br><span class="line">BIN_DIR=bin</span><br><span class="line">H_DIR=<span class="keyword">include</span></span><br><span class="line"><span class="keyword">export</span> CC OBJS BIN OBJS_DIR BIN_DIR H_DIR</span><br><span class="line"></span><br><span class="line"><span class="section">all:CHECK_DIR <span class="variable">$(SUBDIRS)</span></span></span><br><span class="line"><span class="section">CHECK_DIR:</span></span><br><span class="line">	mkdir -p <span class="variable">$(BIN_DIR)</span></span><br><span class="line"><span class="variable">$(SUBDIRS)</span>:ECHO</span><br><span class="line">	make -C <span class="variable">$@</span></span><br><span class="line"><span class="section">ECHO:</span></span><br><span class="line">	@echo <span class="variable">$(SUBDIRS)</span></span><br><span class="line">	@echo begin compile</span><br><span class="line"></span><br><span class="line"><span class="meta"><span class="keyword">.PHONY</span>: clean clean-o</span></span><br><span class="line"><span class="section">clean: clean-o</span></span><br><span class="line">	@rm -rf <span class="variable">$(BIN_DIR)</span></span><br><span class="line"><span class="section">clean-o:</span></span><br><span class="line">	@<span class="variable">$(RM)</span> <span class="variable">$(OBJS_DIR)</span>/*.o</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<p>然后执行 make ，会看到有以下输出信息：</p>
<details class="folding-tag" blue><summary> 点击查看输出信息 </summary>
              <div class='content'>
              <figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">mkdir -p bin</span><br><span class="line">fun1 fun2 main obj</span><br><span class="line">begin compile</span><br><span class="line">make -C fun1</span><br><span class="line">make[1]: 进入目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/fun1”</span><br><span class="line">gcc -c fun1.c -o ../obj/fun1.o</span><br><span class="line">make[1]: 离开目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/fun1”</span><br><span class="line">make -C fun2</span><br><span class="line">make[1]: 进入目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/fun2”</span><br><span class="line">gcc -c fun2.c -o ../obj/fun2.o</span><br><span class="line">make[1]: 离开目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/fun2”</span><br><span class="line">make -C main</span><br><span class="line">make[1]: 进入目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/main”</span><br><span class="line">gcc -c main.c -I ../include -o ../obj/main.o</span><br><span class="line">make[1]: 离开目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/main”</span><br><span class="line">make -C obj</span><br><span class="line">make[1]: 进入目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/obj”</span><br><span class="line">gcc -o ../bin/myapp fun1.o fun2.o main.o</span><br><span class="line">make[1]: 离开目录“/mnt/hgfs/sharedfiles/2Linux/test/LV02/05Makefile/maketest/obj”</span><br></pre></td></tr></table></figure>
              </div>
            </details>

<p>我们最终生成目标文件为 main ，并且，它将会被存放到 .&#x2F;bin 目录下。</p>

    </div>

    
    
    

    <footer class="post-footer">




    <div>
        
            <div style="text-align:center;color: #ccc;font-size:14px;">
            ----------本文结束
            <i class="fas fa-fan fa-spin" style="color: #FF1493; font-size: 1rem"></i>
            感谢您的阅读----------
            </div>
        
    </div>





  
  <div class="my_post_copyright"> 
    <p><span>文章标题:</span><a href="/post/35083dd3.html">LV02-05-Makefile-06-文件包含和嵌套执行</a></p>
    <p><span>文章作者:</span><a href="/" title="欢迎访问 《苏木》 的学习笔记">苏木</a></p>
    <p><span>发布时间:</span>2022年03月23日 - 13:57</p>
    <p><span>最后更新:</span>2025年06月14日 - 00:25</p>
    <p><span>原始链接:</span><a href="/post/35083dd3.html" title="LV02-05-Makefile-06-文件包含和嵌套执行">https://sumumm.github.io/post/35083dd3.html</a></p>
    <p><span>许可协议:</span><i class="fab fa-creative-commons"></i> <a rel="license" href= "https://creativecommons.org/licenses/by-nc-nd/4.0/" target="_blank" title="Attribution-NonCommercial-NoDerivatives 4.0 International (CC BY-NC-ND 4.0)">署名-非商业性使用-禁止演绎 4.0 国际</a> 转载请保留原文链接及作者。</p>  
  </div>
  


          <div class="post-tags">
              <a href="/tags/LV02-%E7%BC%96%E8%AF%91%E5%9F%BA%E7%A1%80/" rel="tag"><i class="fa fa-tag"></i> LV02-编译基础</a>
              <a href="/tags/makefile/" rel="tag"><i class="fa fa-tag"></i> makefile</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/post/8aa811b0.html" rel="prev" title="LV02-05-Makefile-07-条件判断和函数">
                  <i class="fa fa-angle-left"></i> LV02-05-Makefile-07-条件判断和函数
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/post/3f885507.html" rel="next" title="LV02-05-Makefile-05-文件搜索">
                  LV02-05-Makefile-05-文件搜索 <i class="fa fa-angle-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">

  <div class="copyright">
    &copy; 2017 – 
    <span itemprop="copyrightYear">2025</span>
    <span class="with-love">
      <i class="fa fa-heart"></i>
    </span>
    <span class="author" itemprop="copyrightHolder">苏木</span>
  </div>
<div class="wordcount">
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-line"></i>
    </span>
      <span>站点总字数：</span>
    <span title="站点总字数">3.7m</span>
  </span>
  <span class="post-meta-item">
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
      <span>站点阅读时长 &asymp;</span>
    <span title="站点阅读时长">225:26</span>
  </span>
</div>




    <span id="sitetime"></span>
    <script defer language=javascript>
        function siteTime()
        {
            window.setTimeout("siteTime()", 1000);
            var seconds = 1000;
            var minutes = seconds * 60;
            var hours = minutes * 60;
            var days = hours * 24;
            var years = days * 365;
            var today = new Date();
            var todayYear = today.getFullYear();
            var todayMonth = today.getMonth()+1;
            var todayDate = today.getDate();
            var todayHour = today.getHours();
            var todayMinute = today.getMinutes();
            var todaySecond = today.getSeconds();
            /*==================================================
            Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳)
            year        - 作为date对象的年份，为4位年份值
            month       - 0-11之间的整数，做为date对象的月份
            day         - 1-31之间的整数，做为date对象的天数
            hours       - 0(午夜24点)-23之间的整数，做为date对象的小时数
            minutes     - 0-59之间的整数，做为date对象的分钟数
            seconds     - 0-59之间的整数，做为date对象的秒数
            microseconds - 0-999之间的整数，做为date对象的毫秒数
            ==================================================*/
            var t1 = Date.UTC(2017, 
                              5, 
                              19, 
                              0, 
                              0, 
                              0); //北京时间
            var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond);
            var diff = t2-t1;
            var diffYears = Math.floor(diff/years);
            var diffDays = Math.floor((diff/days)-diffYears*365);
            var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours);
            var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes);
            var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds);
            document.getElementById("sitetime").innerHTML="已在这里 "+diffYears+" 年 "+diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒";
        }
        siteTime();
    </script>



    </div>
  </footer>

  
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up fa-lg"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/next-theme-pjax/0.6.0/pjax.min.js" integrity="sha256-vxLn1tSKWD4dqbMRyv940UYw4sXgMtYcK6reefzZrao=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancyapps-ui/5.0.28/fancybox/fancybox.umd.js" integrity="sha256-ytMJGN3toR+a84u7g7NuHm91VIR06Q41kMWDr2pq7Zo=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js" integrity="sha256-mOFREFhqmHeQbXpK2lp4nA3qooVgACfh88fpJftLBbc=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  <script src="https://cdnjs.cloudflare.com/ajax/libs/hexo-generator-searchdb/1.4.1/search.js" integrity="sha256-1kfA5uHPf65M5cphT2dvymhkuyHPQp5A53EGZOnOLmc=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>




  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>


  




  

  <script class="next-config" data-name="enableMath" type="application/json">false</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.2/es5/tex-mml-chtml.js","integrity":"sha256-MASABpB4tYktI2Oitl4t+78w/lyA+D7b/s9GEP0JOGI="}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


 
        <div id="click-show-text"
            data-mobile = false
            data-text = 富强,民主,文明,和谐,自由,平等,公正,法制,爱国,敬业,诚信,友善
            data-fontsize = 15px
            data-random= false>
        </div>
       

      
        <script async src=https://cdn.jsdelivr.net/npm/hexo-next-mouse-effect@latest/click/showText.js></script>
      

      
    




    <script async src="/js/fancybox_param.js"></script>





<!-- APlayer本体 -->



</body>
</html>
